package com.py.androidUtils.UI.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.py.androidUtils.UI.model.ReportView;
import com.py.androidUtils.base.BaseCommAdapter;
import com.readyidu.app.R;

public class ReportAdapter extends BaseCommAdapter<ReportView> {
	private LayoutInflater inflater;

	public ReportAdapter(Context context) {
		inflater = LayoutInflater.from(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.common_report_item, null);
			holder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
			holder.title = (TextView) convertView.findViewById(R.id.title);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		ReportView reportView = (ReportView) listData.get(position);
		if (reportView.isSelect()) {
			holder.imageView.setImageResource(R.drawable.radio_select);
		} else {
			holder.imageView.setImageResource(R.drawable.radio_nomal);
		}
		holder.title.setText(reportView.getName());
		return convertView;
	}

	private final class ViewHolder {
		private ImageView imageView;
		private TextView title;
	}
}
